<?php 
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\model;


use app\common\model\BaseModel;
use think\facade\Db;

/**
 * 通知书-模型
 * @author 牧羊人
 * @since: 2021/12/28
 * Class OfPatentNotice
 * @package app\admin\model
 */
class OfPatentNotice extends BaseModel
{
    // 设置数据表名
    protected $name = "of_patent_notice";

    /**
     * 获取缓存信息
     * @param int $id 记录ID
     * @return \app\common\model\数据信息|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 牧羊人
     * @since: 2021/12/28
     */
    public function getInfo($id)
    {
        $info = parent::getInfo($id); // TODO: Change the autogenerated stub

        if ($info) {
            if(!empty($info['patent_id'])){
                if($info['type'] == 1){
                    $pInfo = Db::name("of_patent")->where("id",$info['patent_id'])->find();
                    if(!empty($pInfo)){                    
                        $info['patent_name'] = $pInfo['patent_name'];
                        $info['number'] = $pInfo['number'];
                    }
                }elseif ($info['type'] == 2) {
                    $trademark = Db::name('of_trademark')->where('id',$info['patent_id'])->find();
                    if($trademark){
                        $info['trademark_name'] = $trademark['brand_name'];
                        $info['apply_number'] = $trademark['apply_number'];
                        $info['number']   = $trademark['project_number'];
                    }
                    
                }elseif ($info['type'] == 3) {
                    
                }
                
            }else{                
                $info['patent_name'] = '';
                $info['number'] = '';
            }          
            $info['company_name'] = '';
            if(!empty($info['company_id'])){
                $info['company_name'] = Db::name("of_company")->where("id",$info['company_id'])->value("name");
            }

        }
        return $info;
    }
}